package com.zhangxin.aiInterview.manager.redis.audio_speed;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 存储用户的语速和文本内容
 */
@Component
public class TakeInSpeed {
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    public void takeInSpeed(Long userId, String text, String audioSpeed) {
        try {
            String key = "AI_interview:audioSpeed:" + userId;
            // 使用 Hash 存储，field 是文字内容，value 是语速
            stringRedisTemplate.opsForHash().put(key, text, audioSpeed);
        } catch (Exception e) {
            System.out.println("Redis 存储语速 Hash 数据失败: " + e.getMessage());
        }
    }
}
